package com.qianxunclub.chapter13;

import com.google.gson.Gson;
/**
 * 单例：双重校验锁 获取 gson
 */
public class GsonUtil {
    private volatile static Gson gson;
    private GsonUtil(){}

    public static Gson getInstance(){
        if(gson==null){
            synchronized (GsonUtil.class){
                if(gson==null)
                    return gson=new Gson();
            }
        }
        return gson;
    }
}
